From: Wen Congyang Date: Thu, 18 Sep 2014 10:08:45 +0000 (+0200) Subject: x86/hvm: always set pending event injection when loading VMC[BS] state X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~4403 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=6a10e2385a7409a4f88248d09a80a03b2bdaca76;p=xen.git x86/hvm: always set pending event injection when loading VMC[BS] state In colo mode, secondary vm is running, so VM_ENTRY_INTR_INFO may valid before restoring vmcs. If there is no pending event after restoring vm, we should clear it. Signed-off-by: Wen Congyang Also clear pending software exceptions. Copy the fix to SVM as well. Signed-off-by: Tim Deegan Acked-by: Kevin Tian Acked-by: Aravind Gopalakrishnan --- diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index b5188e6aeb..5d404cea6e 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -321,17 +321,16 @@ static int svm_vmcb_restore(struct vcpu *v, struct hvm_hw_cpu *c) vmcb_set_h_cr3(vmcb, pagetable_get_paddr(p2m_get_pagetable(p2m))); } - if ( c->pending_valid ) + if ( c->pending_valid && + hvm_event_needs_reinjection(c->pending_type, c->pending_vector) ) { gdprintk(XENLOG_INFO, "Re-injecting %#"PRIx32", %#"PRIx32"\n", c->pending_event, c->error_code); - - if ( hvm_event_needs_reinjection(c->pending_type, c->pending_vector) ) - { - vmcb->eventinj.bytes = c->pending_event; - vmcb->eventinj.fields.errorcode = c->error_code; - } + vmcb->eventinj.bytes = c->pending_event; + vmcb->eventinj.fields.errorcode = c->error_code; } + else + vmcb->eventinj.bytes = 0; vmcb->cleanbits.bytes = 0; paging_update_paging_modes(v); diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index d3e7ac91c7..61b923f013 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -510,23 +510,22 @@ static int vmx_vmcs_restore(struct vcpu *v, struct hvm_hw_cpu *c) __vmwrite(GUEST_DR7, c->dr7); - vmx_vmcs_exit(v); - - paging_update_paging_modes(v); - - if ( c->pending_valid ) + if ( c->pending_valid && + hvm_event_needs_reinjection(c->pending_type, c->pending_vector) ) { gdprintk(XENLOG_INFO, "Re-injecting %#"PRIx32", %#"PRIx32"\n", c->pending_event, c->error_code); - - if ( hvm_event_needs_reinjection(c->pending_type, c->pending_vector) ) - { - vmx_vmcs_enter(v); - __vmwrite(VM_ENTRY_INTR_INFO, c->pending_event); - __vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, c->error_code); - vmx_vmcs_exit(v); - } + __vmwrite(VM_ENTRY_INTR_INFO, c->pending_event); + __vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, c->error_code); + } + else + { + __vmwrite(VM_ENTRY_INTR_INFO, 0); + __vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, 0); } + vmx_vmcs_exit(v); + + paging_update_paging_modes(v); return 0; }